﻿///<copyright>
/// Copyright © 2009 Stephen Styrchak. All Rights Reserved.
/// Portions copyright (C) Microsoft Corporation. All rights reserved.
///</copyright>
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Ferpect.ComponentModel.Sprites
{
    public class ExplosionParticlesSprite : ParticlesSprite
    {
        public ExplosionParticlesSprite()
        {
            // high initial speed with lots of variance.  make the values closer
            // together to have more consistently circular explosions.
            MinInitialSpeed = 40;
            MaxInitialSpeed = 500;

            // doesn't matter what these values are set to, acceleration is tweaked in
            // the override of InitializeParticle.
            MinAcceleration = 0;
            MaxAcceleration = 0;

            // explosions should be relatively short lived
            MinLifetime = .5f;
            MaxLifetime = 1.0f;

            MinScale = 0.3f;
            MaxScale = 1.0f;

            MinNumParticles = 20;
            MaxNumParticles = 25;

            MinRotationSpeed = -MathHelper.PiOver4;
            MaxRotationSpeed = MathHelper.PiOver4;

            // additive blending is very good at creating fiery effects.
            BlendState = BlendState.Additive;
        }

        protected override void InitializeParticle(ref Particle particle, Microsoft.Xna.Framework.Vector2 where)
        {
            base.InitializeParticle(ref particle, where);
            particle.Acceleration = -particle.Velocity / particle.Lifetime;
        }
    }
}
